package com.jsmtr.rms.service.DUserResumePreview.impl;

import com.jsmtr.rms.dao.DaoService;
import com.jsmtr.rms.entity.*;
import com.jsmtr.rms.service.DUserResumePreview.IMyhrService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class MyhrService implements IMyhrService {

    @Resource
    private DaoService dao;

    public void setDao(DaoService dao) {
        this.dao = dao;
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<DUserResume> getMyDUserResumes(String userid, String prex) throws Exception {
        return dao.find("from DUserResume where userid='" + userid + "' and proid like '" + prex + "%' order by addDate desc");
    }

    @Override
    public List<Map<String, Object>> getDUserResumeFlowInfos(String cardno) throws  Exception{
        String sql=
                "select uflows.uflow flowid,\n" +
                        "       pf.fid  flownumber,\n" +
                        "       pf.pid flowproid,\n" +
                        "       proinfo.pname flowproname,\n" +
                        "       pf.nickname  flownickname,\n" +
                        "       pf.fname  flowname,\n" +
                        "       pf.webname  flowwebname,\n" +
                        "       pf.forder   floworder,\n" +
                        "       pf.state     flowstate,\n" +
                        "       pf.starttime flowstartime,\n" +
                        "       pf.endtime   flowendtime,\n" +
                        "       pf.remark    flowremark,\n" +
                        "       pf.display flowdisplay,\n" +
                        "       duser.id duserid,\n" +
                        "       duser.jid jid,\n" +
                        "       duser.jname jname,\n" +
                        "       case  when ( pf.nickname like '%简历筛选%' or pf.fname like '%简历筛选%') then (select '{\"state\":\"'||u.state||'\",\"fbzt\":\"'||u.op1||'\",\"remark\":\"'||u.sxbz||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "         when (pf.nickname like '%笔试%' or pf.fname like '%笔试%') then (select '{\"address\":\"'||bu.address||'\",\"name\":\"'||bu.kcname||'\",\"msg\":\"'||bu.notice||'\",\"ticketnum\":\"'||bu.ticketnum||'\",\"time\":\"'||bu.starttime||'\",\"state\":\"'||bu.result||'\",\"fbzt\":\"'||bu.op6||'\",\"point\":\"'||bu.point||'\",\"remark\":\"'||bu.remark||'\"}' from dobs_user bu  where bu.userid=uflows.userid )\n" +
                        "           when (pf.nickname like '%资料审核%' or pf.fname like '%资料审核%') then (select '{\"state\":\"'||u.zlstate||'\",\"msg\":\"'||u.zlmsg||'\",\"msgcont\":\"'||u.zlmsgcont||'\",\"fbzt\":\"'||u.op2||'\",\"remark\":\"'||u.zlremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "             when (pf.nickname like '%面试%' or pf.fname like '%面试%') then (select '{\"address\":\"'||mu.address||'\",\"msg\":\"'||mu.notice||'\",\"isconfirm\":\"'||mc.isconfirm||'\",\"confirmtime\":\"'||mc.confirmtime||'\",\"endtime\":\"'||mc.endtime||'\",\"time\":\"'||mu.starttime||'\",\"state\":\"'||mu.result||'\",\"fbzt\":\"'||mu.op7||'\",\"point\":\"'||mu.point||'\",\"remark\":\"'||mu.remark||'\"}' from doms_user mu,doms_confirm mc  where mu.userid=uflows.userid and mu.id=mc.msuserid(+) )\n" +
                        "               when (pf.nickname like '%实作%' or pf.fname like '%实作%') then (select '{\"address\":\"'||ou.address||'\",\"name\":\"'||ou.cont||'\",\"msg\":\"'||ou.notice||'\",\"time\":\"'||ou.starttime||'\",\"state\":\"'||ou.result||'\",\"fbzt\":\"'||ou.op8||'\",\"point\":\"'||ou.point||'\",\"remark\":\"'||ou.bz||'\"}' from dooperation_user ou  where ou.userid=uflows.userid )\n" +
                        "                 when (pf.nickname like '%体检%' or pf.fname like '%体检%') then (select  '{\"address\":\"'||u.tjaddress||'\",\"msg\":\"'||u.tjmsg||'\",\"tjlxr\":\"'||u.tjlxr||'\",\"tjlxdh\":\"'||u.tjlxdh||'\",\"time\":\"'||u.tjtime||'\",\"state\":\"'||u.tjstate||'\",\"fbzt\":\"'||u.op4||'\",\"point\":\"\",\"remark\":\"'||u.tjremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "                   when (pf.nickname like '%背景调查%' or pf.fname like '%背景调查%' or pf.nickname like '%政审%' ) then (select  '{\"state\":\"'||u.zsstate||'\",\"fbzt\":\"'||u.op3||'\",\"remark\":\"'||u.zsremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "                     when (pf.nickname like '%实习%' or pf.fname like '%实习%') then (select  '{\"state\":\"'||u.sxstate||'\",\"fbzt\":\"'||u.op7||'\",\"remark\":\"'||u.sxremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "                        when (pf.nickname like '%录用%' or pf.fname like '%录用%') then (select  '{\"state\":\"'||u.bdstate||'\",\"fbzt\":\"'||u.op5||'\",\"address\":\"'||u.bdaddress||'\",\"remark\":\"'||u.bdremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "                when (pf.nickname like '%签约%' or pf.fname like '%签约%') then (select  '{\"state\":\"'||u.qystate||'\",\"fbzt\":\"'||u.op9||'\",\"remark\":\"'||u.qyremark||'\"}' from duserresume u  where u.id=uflows.userid ) \n"+
        "         end as resumecontent\n" +
                        "  from project_info_flow pf,\n" +
                        "       project_info proinfo,\n" +
                        "      duserresume duser ,\n" +
                        "       (SELECT REGEXP_SUBSTR(pt.tpath, '[^,]+', 1, rownum) uflow,pt.id userid\n" +
                        "          from (select regexp_replace(substr(r.path, 2, length(r.path) - 2),\n" +
                        "                                      '/',\n" +
                        "                                      ',') tpath,r.id\n" +
                        "                  from duserresume r\n" +
                        "                 where r.id =(select id from  (select id,rownum from duserresume  where cardno=:cardno and (proid like 'A_%' or proid like 'B_%') order by adddate desc ) ldr where rownum=1)) pt\n" +
                        "        connect by rownum <= LENGTH(pt.tpath) -\n" +
                        "                   LENGTH(regexp_replace(pt.tpath, ',', '')) + 1) uflows\n" +
                        " where pf.id=uflows.uflow(+)\n" +
                        "   and proinfo.id=pf.pid\n" +
                        "   and duser.proid=pf.pid\n" +
                        "   and duser.id=uflows.userid\n" +
                        "   and (pf.pid like  'A_%' or pf.pid like  'B_%' )\n" +
                        "   order by pf.forder asc";

        HashMap<String,Object> params=new HashMap<>();
        params.put("cardno",cardno);
        return  dao.executeSQLQueryToMap(sql,params);

    }

    @Override
    public List<Map<String, Object>> getDUserResumeFlowInfos(String cardno, String pstart) throws  Exception{
        String sql=
                "select uflows.uflow flowid,\n" +
                        "       pf.fid  flownumber,\n" +
                        "       pf.pid flowproid,\n" +
                        "       proinfo.pname flowproname,\n" +
                        "       pf.nickname  flownickname,\n" +
                        "       pf.fname  flowname,\n" +
                        "       pf.webname  flowwebname,\n" +
                        "       pf.forder   floworder,\n" +
                        "       pf.state     flowstate,\n" +
                        "       pf.starttime flowstartime,\n" +
                        "       pf.endtime   flowendtime,\n" +
                        "       pf.remark    flowremark,\n" +
                        "       pf.display flowdisplay,\n" +
                        "       duser.id duserid,\n" +
                        "       duser.jid jid,\n" +
                        "       duser.jname jname,\n" +
                        "       case  when ( pf.nickname like '%简历筛选%' or pf.fname like '%简历筛选%') then (select '{\"state\":\"'||u.state||'\",\"fbzt\":\"'||u.op1||'\",\"remark\":\"'||u.sxbz||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "         when (pf.nickname like '%笔试%' or pf.fname like '%笔试%') then (select '{\"address\":\"'||bu.address||'\",\"name\":\"'||bu.kcname||'\",\"msg\":\"'||bu.notice||'\",\"ticketnum\":\"'||bu.ticketnum||'\",\"time\":\"'||bu.starttime||'\",\"state\":\"'||bu.result||'\",\"fbzt\":\"'||bu.op6||'\",\"point\":\"'||bu.point||'\",\"remark\":\"'||bu.remark||'\"}' from dobs_user bu  where bu.userid=uflows.userid )\n" +
                        "           when (pf.nickname like '%资料审核%' or pf.fname like '%资料审核%') then (select '{\"state\":\"'||u.zlstate||'\",\"msg\":\"'||u.zlmsg||'\",\"msgcont\":\"'||u.zlmsgcont||'\",\"fbzt\":\"'||u.op2||'\",\"remark\":\"'||u.zlremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "             when (pf.nickname like '%面试%' or pf.fname like '%面试%') then (select '{\"address\":\"'||mu.address||'\",\"msg\":\"'||mu.notice||'\",\"isconfirm\":\"'||mc.isconfirm||'\",\"confirmtime\":\"'||mc.confirmtime||'\",\"endtime\":\"'||mc.endtime||'\",\"time\":\"'||mu.starttime||'\",\"state\":\"'||mu.result||'\",\"fbzt\":\"'||mu.op7||'\",\"point\":\"'||mu.point||'\",\"remark\":\"'||mu.remark||'\"}' from doms_user mu,doms_confirm mc  where mu.userid=uflows.userid and mu.id=mc.msuserid(+) )\n" +
                        "               when (pf.nickname like '%实作%' or pf.fname like '%实作%') then (select '{\"address\":\"'||ou.address||'\",\"name\":\"'||ou.cont||'\",\"msg\":\"'||ou.notice||'\",\"time\":\"'||ou.starttime||'\",\"state\":\"'||ou.result||'\",\"fbzt\":\"'||ou.op8||'\",\"point\":\"'||ou.point||'\",\"remark\":\"'||ou.bz||'\"}' from dooperation_user ou  where ou.userid=uflows.userid )\n" +
                        "                 when (pf.nickname like '%体检%' or pf.fname like '%体检%') then (select  '{\"address\":\"'||u.tjaddress||'\",\"msg\":\"'||u.tjmsg||'\",\"tjlxr\":\"'||u.tjlxr||'\",\"tjlxdh\":\"'||u.tjlxdh||'\",\"time\":\"'||u.tjtime||'\",\"state\":\"'||u.tjstate||'\",\"fbzt\":\"'||u.op4||'\",\"point\":\"\",\"remark\":\"'||u.tjremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "                   when (pf.nickname like '%背景调查%' or pf.fname like '%背景调查%' or pf.nickname like '%政审%' ) then (select  '{\"state\":\"'||u.zsstate||'\",\"fbzt\":\"'||u.op3||'\",\"remark\":\"'||u.zsremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "                     when (pf.nickname like '%实习%' or pf.fname like '%实习%') then (select  '{\"state\":\"'||u.sxstate||'\",\"fbzt\":\"'||u.op7||'\",\"remark\":\"'||u.sxremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "                        when (pf.nickname like '%录用%' or pf.fname like '%录用%') then (select  '{\"state\":\"'||u.bdstate||'\",\"fbzt\":\"'||u.op5||'\",\"address\":\"'||u.bdaddress||'\",\"remark\":\"'||u.bdremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "                when (pf.nickname like '%签约%' or pf.fname like '%签约%') then (select  '{\"state\":\"'||u.qystate||'\",\"fbzt\":\"'||u.op9||'\",\"remark\":\"'||u.qyremark||'\"}' from duserresume u  where u.id=uflows.userid) \n"+
                        "         end as resumecontent\n" +
                        "  from project_info_flow pf,\n" +
                        "       project_info proinfo,\n" +
                        "      duserresume duser ,\n" +
                        "       (SELECT REGEXP_SUBSTR(pt.tpath, '[^,]+', 1, rownum) uflow,pt.id userid\n" +
                        "          from (select regexp_replace(substr(r.path, 2, length(r.path) - 2),\n" +
                        "                                      '/',\n" +
                        "                                      ',') tpath,r.id\n" +
                        "                  from duserresume r\n" +
                        "                 where r.id =(select id from  (select id,rownum from duserresume  where cardno=:cardno and proid like  :ptype order by adddate desc ) ldr where rownum=1)) pt\n" +
                        "        connect by rownum <= LENGTH(pt.tpath) -\n" +
                        "                   LENGTH(regexp_replace(pt.tpath, ',', '')) + 1) uflows\n" +
                        " where pf.id=uflows.uflow(+)\n" +
                        "   and proinfo.id=pf.pid\n" +
                        "   and duser.id=uflows.userid\n" +
                        "   and  pf.id=uflows.uflow\n" +
                        "   and duser.proid=pf.pid\n" +
                        "   and (pf.pid like  :ptype )\n" +
                        "   order by pf.forder asc";

        HashMap<String,Object> params=new HashMap<>();
        params.put("cardno",cardno);
        params.put("ptype",pstart+"_%");
        return  dao.executeSQLQueryToMap(sql,params);

    }

    @Override
    public List<Map<String, Object>> getZGZCJDUserResumeFlowInfos(String cardno) throws  Exception{
        String sql=
                "select uflows.uflow flowid,\n" +
                        "       pf.fid  flownumber,\n" +
                        "       pf.pid flowproid,\n" +
                        "       proinfo.pname flowproname,\n" +
                        "       pf.nickname  flownickname,\n" +
                        "       pf.fname  flowname,\n" +
                        "       pf.webname  flowwebname,\n" +
                        "       pf.forder   floworder,\n" +
                        "       pf.state     flowstate,\n" +
                        "       pf.starttime flowstartime,\n" +
                        "       pf.endtime   flowendtime,\n" +
                        "       pf.remark    flowremark,\n" +
                        "       pf.display flowdisplay,\n" +
                        "       duser.id duserid,\n" +
                        "       duser.jid jid,\n" +
                        "       duser.jname jname,\n" +
                        "       case  when ( pf.nickname like '%简历筛选%' or pf.fname like '%简历筛选%') then (select '{\"state\":\"'||u.state||'\",\"fbzt\":\"'||u.op1||'\",\"remark\":\"'||u.sxbz||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "         when (pf.nickname like '%笔试%' or pf.fname like '%笔试%') then (select '{\"address\":\"'||bu.address||'\",\"name\":\"'||bu.kcname||'\",\"msg\":\"'||bu.notice||'\",\"ticketnum\":\"'||bu.ticketnum||'\",\"time\":\"'||bu.starttime||'\",\"state\":\"'||bu.result||'\",\"fbzt\":\"'||bu.op6||'\",\"point\":\"'||bu.point||'\",\"remark\":\"'||bu.remark||'\"}' from dobs_user bu  where bu.userid=uflows.userid )\n" +
                        "           when (pf.nickname like '%资料审核%' or pf.fname like '%资料审核%') then (select '{\"state\":\"'||u.zlstate||'\",\"msg\":\"'||u.zlmsg||'\",\"msgcont\":\"'||u.zlmsgcont||'\",\"fbzt\":\"'||u.op2||'\",\"remark\":\"'||u.zlremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "             when (pf.nickname like '%面试%' or pf.fname like '%面试%') then (select '{\"address\":\"'||mu.address||'\",\"msg\":\"'||mu.notice||'\",\"isconfirm\":\"'||mc.isconfirm||'\",\"confirmtime\":\"'||mc.confirmtime||'\",\"endtime\":\"'||mc.endtime||'\",\"time\":\"'||mu.starttime||'\",\"state\":\"'||mu.result||'\",\"fbzt\":\"'||mu.op7||'\",\"point\":\"'||mu.point||'\",\"remark\":\"'||mu.remark||'\"}' from doms_user mu,doms_confirm mc  where mu.userid=uflows.userid and mu.id=mc.msuserid(+) )\n" +
                        "               when (pf.nickname like '%实作%' or pf.fname like '%实作%') then (select '{\"address\":\"'||ou.address||'\",\"name\":\"'||ou.cont||'\",\"msg\":\"'||ou.notice||'\",\"time\":\"'||ou.starttime||'\",\"state\":\"'||ou.result||'\",\"fbzt\":\"'||ou.op8||'\",\"point\":\"'||ou.point||'\",\"remark\":\"'||ou.bz||'\"}' from dooperation_user ou  where ou.userid=uflows.userid )\n" +
                        "                 when (pf.nickname like '%体检%' or pf.fname like '%体检%') then (select  '{\"address\":\"'||u.tjaddress||'\",\"msg\":\"'||u.tjmsg||'\",\"tjlxr\":\"'||u.tjlxr||'\",\"tjlxdh\":\"'||u.tjlxdh||'\",\"time\":\"'||u.tjtime||'\",\"state\":\"'||u.tjstate||'\",\"fbzt\":\"'||u.op4||'\",\"point\":\"\",\"remark\":\"'||u.tjremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "                   when (pf.nickname like '%背景调查%' or pf.fname like '%背景调查%' or pf.nickname like '%政审%' ) then (select  '{\"state\":\"'||u.zsstate||'\",\"fbzt\":\"'||u.op3||'\",\"remark\":\"'||u.zsremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "                     when (pf.nickname like '%实习%' or pf.fname like '%实习%') then (select  '{\"state\":\"'||u.sxstate||'\",\"fbzt\":\"'||u.op7||'\",\"remark\":\"'||u.sxremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "                        when (pf.nickname like '%录用%' or pf.fname like '%录用%') then (select  '{\"state\":\"'||u.bdstate||'\",\"fbzt\":\"'||u.op5||'\",\"address\":\"'||u.bdaddress||'\",\"remark\":\"'||u.bdremark||'\"}' from duserresume u  where u.id=uflows.userid )\n" +
                        "                when (pf.nickname like '%签约%' or pf.fname like '%签约%') then (select  '{\"state\":\"'||u.qystate||'\",\"fbzt\":\"'||u.op9||'\",\"remark\":\"'||u.qyremark||'\"}' from duserresume u  where u.id=uflows.userid) \n"+
                        "         end as resumecontent\n" +
                        "  from project_info_flow pf,\n" +
                        "       project_info proinfo,\n" +
                        "      duserresume duser ,\n" +
                        "       (SELECT REGEXP_SUBSTR(pt.tpath, '[^,]+', 1, rownum) uflow,pt.id userid\n" +
                        "          from (select regexp_replace(substr(r.path, 2, length(r.path) - 2),\n" +
                        "                                      '/',\n" +
                        "                                      ',') tpath,r.id\n" +
                        "                  from duserresume r\n" +
                        "                 where r.id =(select id from  (select id,rownum from duserresume  where cardno=:cardno and proid like 'E_%' order by adddate desc ) ldr where rownum=1)) pt\n" +
                        "        connect by rownum <= LENGTH(pt.tpath) -\n" +
                        "                   LENGTH(regexp_replace(pt.tpath, ',', '')) + 1) uflows\n" +
                        " where proinfo.id=pf.pid\n" +
                        "   and duser.id=uflows.userid\n" +
                        "   and  pf.id=uflows.uflow\n" +
                        "   and duser.proid=proinfo.id\n"+
                        "   and duser.proid=pf.pid\n" +
                        "   and (pf.pid like 'E_%')\n" +
                                        "   order by pf.forder asc";


        HashMap<String,Object> params=new HashMap<>();
        params.put("cardno",cardno);
        return  dao.executeSQLQueryToMap(sql,params);

    }

    @Override
    public DUserResume getDUserResume(String id, String userid) throws Exception {
        return (DUserResume) dao.findUnique("from DUserResume where userid='" + userid + "' and id='" + id + "'");
    }

    @Override
    public DUserResume getDUserResume(String id) throws Exception {
        return (DUserResume) dao.findUnique("from DUserResume where id='" + id + "'");
    }

    //教育背景
    @SuppressWarnings("unchecked")
    @Override
    public List<DUserEducation> getUserEducation(String rid) throws Exception {
        return dao.find("from DUserEducation where rid='" + rid + "'");
    }

    //工作经验
    @SuppressWarnings("unchecked")
    @Override
    public List<DUserWorkExperience> getUserWorkExperience(String rid) throws Exception {
        return dao.find("from DUserWorkExperience where rid='" + rid + "'");
    }

    //培训经历
    @SuppressWarnings("unchecked")
    @Override
    public List<DUserTraining> getUserTraining(String rid) throws Exception {
        return dao.find("from DUserTraining where rid='" + rid + "'");
    }

    @Override
    public ProjectInfo getProjectInfo(String id) throws Exception {
        return (ProjectInfo) dao.findUnique("from ProjectInfo where id='" + id + "' ");
    }

    @Override
    public ProjectInfoFlow getProjectInfoFlow(String id) throws Exception {
        return (ProjectInfoFlow) dao.findUnique("from ProjectInfoFlow where id='" + id + "' ");
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<ProjectInfoFlow> getProjectInfoFlows(String pid, String deptcode) throws Exception {
        if (deptcode == null) {
            return dao.find("from ProjectInfoFlow where pid='" + pid + "' order by forder");
        } else {
            return dao.find("from ProjectInfoFlow where pid='" + pid + "' and deptcode='" + deptcode + "' order by forder");
        }
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<HRGXUser> getGXUsers(String code) throws Exception {
        return dao.find("from HRGXUser where code='" + code + "' order by adddate desc");
    }

    @Override
    public HRGXUser getGXUser(String pid, String code) throws Exception {
        return (HRGXUser) dao.findUnique("from HRGXUser where pid='" + pid + "' and code='" + code + "'");
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<HRZZUser> getZZUsers(String code) throws Exception {
        return dao.find("from HRZZUser where code='" + code + "' order by adddate desc");
    }

    @Override
    public HRZZUser getZZUser(String pid, String code) throws Exception {
        return (HRZZUser) dao.findUnique("from HRZZUser where pid='" + pid + "' and code='" + code + "'");
    }

    @Override
    public DoMSUser getMsUser(String fid, String userid) throws Exception {
        return (DoMSUser) dao.findUnique("from DoMSUser where fid='" + fid + "' and userid='" + userid + "'");
    }

    @Override
    public DoBSUser getBsUser(String fid, String userid) throws Exception {
        return (DoBSUser) dao.findUnique("from DoBSUser where fid='" + fid + "' and userid='" + userid + "'");
    }

    @Override
    public DoBSUser getBsUser(String id) throws Exception {
        return (DoBSUser) dao.findUnique("from DoBSUser where id='" + id + "'");
    }

    @Override
    public DoOperationUser getOperationUser(String fid, String userid) throws Exception {
        return (DoOperationUser) dao.findUnique("from DoOperationUser where fid='" + fid + "' and userid='" + userid + "'");
    }



    @Override
    public long getSZGiveUpCount(String pid, String userid) throws Exception {
        String sql = "select count(1) from DUserResume where userid='" + userid + "' and proid='" + pid + "' and fqstate='已放弃'";
        return (Long) dao.findUnique(sql);
    }

    @Override
    public Object getMsUserDetial(String fid, String userid) throws Exception {
        String findSql="select u.*,c.id as confrimid,c.endtime,c.isconfirm,c.confirmtime,c.type from doms_user u , doms_confirm c where u.id=c.msuserid(+) and u.fid='" + fid + "' and u.userid='" + userid + "'";
        return dao.findUniqueSql(findSql);
    }

    @Override
    public List<Map<String, Object>> getMsUserDetialByMap(String fid, String userid) throws Exception {
        String findSql="select u.*,c.id as confrimid,c.endtime,c.isconfirm,c.confirmtime,c.type from doms_user u , doms_confirm c where u.id=c.msuserid(+) and u.fid=:fid and u.userid=:userid ";
        Map<String,Object> prams=new HashMap<>();
        prams.put("fid",fid);
        prams.put("userid",userid);
        return dao.executeSQLQueryToMap(findSql,prams);
    }

    @Override
    public Object getUserZysx(String pid, String fid, String userid) throws Exception {
        Map params=new HashMap();
        String hql="select z.remark from do_zysx z where z.pid=:pid and z.fid=:fid and z.userid=:userid";
        params.put("pid",pid);
        params.put("fid",fid);
        params.put("userid",userid);
        List resultList= dao.executeSQLQuery(hql,params);
        if(resultList!=null&&resultList.size()>0){
            return  resultList.get(0);
        }
        return  null;
    }
}
